<extend name="Common/common" />
<block name="main">
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <include file="Common/nav-header"/> <!--顶部-->
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加分类</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t " method="post" action="{:U('add')}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">高级类别：</label>
                            <div class="col-sm-9">
                                <select name="high_id" id="high_id">
                                    <option value="0">请选择高级分类</option>
                                    <foreach name="high_level" item="vo">
                                        <option value="{$vo.id}" <if condition="($vo.id eq $data['high_id'])">selected</if> >{$vo.high_name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">名称：</label>
                            <div class="col-sm-3">
                                <input  type="text" id="name" class="form-control"  name="middle_name" value="{$data.middle_name}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="col-sm-3">
                                <input  type="text" id="sort"  class="form-control" name="sort" value="{$data.sort}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否推荐：</label>
                            <input type="radio"  value="0"  name="is_recommend" <if condition="($data.is_recommend neq 1)"> checked</if> />
                                不推荐
                            <input type="radio"  value="1"  name="is_recommend" <if condition="($data.is_recommend eq 1)"> checked</if> />
                                推荐
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <input type="hidden" name="id" value="{$data.id}">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <!--尾部-->
        <include file="Common/admin:footer"/>
    </div>

<script>
    $('form').submit(function(){
        var high_id = $('#high_id').val();
        var name = $('#name').val();
        var sort = $("#sort").val();
        if(high_id == 0){
            layer.msg('请选择高级分类',{time:1000});
            return false;
        }
        if(name == ''){
            layer.msg('请填写名称',{time:1000});
            return false;
        }
        if(!sort || isNaN(sort)){
            layer.msg('请填写排序，并且为数字',{time:1000});
            return false;
        }
    });
</script>

</block>

